package com.czh.springboot04.service.serviceimpl;

import com.czh.springboot04.entity.Charge;
import com.czh.springboot04.entity.ChargeType;
import com.czh.springboot04.mapper.ChargeMapper;
import com.czh.springboot04.mapper.ChargeTypeMapper;
import com.czh.springboot04.service.ChargeTypeService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ChargeTypeServiceImpl implements ChargeTypeService {
    @Autowired
    private ChargeTypeMapper chargeTypeMapper;
    @Override
    public int insert(ChargeType chargeType) {
        int i = chargeTypeMapper.insert(chargeType);
        return i;
    }

    @Override
    public int update(ChargeType chargeType) {
        int i = chargeTypeMapper.update(chargeType);
        return i;
    }

    @Override
    public int delete(int id) {
        int i = chargeTypeMapper.delete(id);
        return i;
    }

    @Override
    public PageInfo<ChargeType> selectByPage(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<ChargeType> list = chargeTypeMapper.selectByPage();
        PageInfo<ChargeType> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }
    @Override
    public ChargeType selectById(int id) {
        return chargeTypeMapper.selectById(id);
    }
}
